package com.cssy.yd.basic.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.byd.acegiext.domain.User;
import com.cssy.yd.basic.dao.BasicCompanyDAO;
import com.cssy.yd.basic.entity.BasicCompanyDO;
import com.cssy.yd.basic.service.IBasicCompanyService;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.IDCodeTypeUtil;


@Service("basicCompanyService")
public class BasicCompanyServiceImpl implements IBasicCompanyService{

	
	@Resource(name="basicCompanyDAO")	
	private BasicCompanyDAO basicCompanyDAO;
	
	
	@Override
	public SearchResult findListByExample(SearchConditions scs)
			throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<BasicCompanyDO>  list=basicCompanyDAO.find(scs);
		rs.setRecordCount(basicCompanyDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public Integer delete(String id, User user) throws SyBaseException {

		basicCompanyDAO.deleteBasicCompanyDOByPrimaryKey(id);
	
		return null;
	}

	@Override
	public Integer update(BasicCompanyDO t, User user) throws SyBaseException {
		t.setDuuser(user.getName());
		t.setDutime(new Date());
		return basicCompanyDAO.updateBasicCompanyDO(t);
	}

	@Override
	public BasicCompanyDO save(BasicCompanyDO t, User user)
			throws SyBaseException {
		t.setDcruser(user.getName());
		t.setDctime(new Date());
		t.setId(IDCodeTypeUtil.getId());
		basicCompanyDAO.insertBasicCompanyDO(t);
		return t;
	}

	@Override
	public BasicCompanyDO findListById(String id) throws SyBaseException {
		
		return basicCompanyDAO.findBasicCompanyDOByPrimaryKey(id);
	}
	@Override
	public List<BasicCompanyDO> find(SearchConditions cs) throws SyBaseException {
		List<BasicCompanyDO> companylist = basicCompanyDAO.find(cs);
		return companylist ;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}

//	@Override
//	public SearchResult findTreeByExample(SearchConditions scs)
//			throws SyBaseException {
//		SearchResult rs=new SearchResult(scs);
//		List<BasicCompanyDO>  list=basicCompanyDAO.findgys(scs);
//		rs.setRecordCount(basicCompanyDAO.count(scs));
//		rs.setResults(list);
//		return rs;
//	}
}
